public class User
{
    public string Username { get; set; }
    public string Password { get; set; }
}

public class MyDbContext : DbContext
{
    public DbSet<User> Users { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlite("Data Source=MyDatabase.sqlite");
    }
    // 这些代码使用了LINQ来插入和查询用户。db.Users.Add方法用于插入用户，db.SaveChanges方法用于保存更改到数据库。db.Users.Any方法用于检查是否存在满足条件的用户。
    public void InsertUser(string username, string password)
{
    string passwordHash = ComputeSha256Hash(password);

    using (var db = new MyDbContext())
    {
        db.Users.Add(new User { Username = username, Password = passwordHash });
        db.SaveChanges();
    }
}
public bool ValidateUser(string username, string password)
{
    string passwordHash = ComputeSha256Hash(password);

    using (var db = new MyDbContext())
    {
        return db.Users.Any(user => user.Username == username && user.Password == passwordHash);
    }
}
}